//class Person{
//    private   String name;
//    private   int age;
//    private String sex;
//    private static int count=0;
//
//    //构造方法
//    public Person(String name,int age,String sex){
//        this.name=name;
//        this.age=age;
//        this.sex=sex;
//    }
//
//    public void show(){
//        System.out.println("name:"+ name +" age:" +age +" sex:" + sex);
//    }
//}

import demo.Demo1;
import jdk.nashorn.internal.ir.CatchNode;

import static javax.print.attribute.standard.MediaSizeName.B;
import static javax.print.attribute.standard.MediaSizeName.C;

class Animal{
    protected String name;//继承访问权限

    public Animal(String name) {
        this.name = name;
    }

    public void eat(String food){
        System.out.println("我是一只小动物");
        System.out.println(this.name + "正在吃" + food);
    }
}

class Bird extends Animal{

    public Bird(String name) {
        super(name);
    }
    @Override
    public void eat(String food){//重写父类中的eat方法
        System.out.println("我是一只小鸟");
        System.out.println(this.name+"正在吃"+food);
    }
    public void fly(){
        System.out.println(this.name+"正在飞");
    }
}
class Cat extends Animal{
    public Cat(String name){
        super(name);
    }
}

public class Test {
    public static void main(String[] args) {
        Animal animal=new Bird("边边");
        Animal animal1=new Cat("橙子");
        if(animal1 instanceof Bird){
            Bird bird=(Bird) animal1;
            bird.fly();
        }
        animal.eat("谷子");
        Bird bird=(Bird)animal;
        bird.fly();
    }
}
